package cn.wangzengqiang.study.designpattern.observer.own.java;

import java.util.Observable;
import java.util.Observer;

/**
 * 订阅者：工一
 */
public class Gongyi implements Observer {
    public void registerSubject(Observable observable) {
        observable.addObserver(this);
    }

    @Override
    public void update(Observable o, Object arg) {
        if (o instanceof LogicalThinking) {
            LogicalThinking logicalThinking = (LogicalThinking) o;
            System.out.println(logicalThinking.getClass().getSimpleName() + "'s msg -- >" + logicalThinking.getMsg());
        }
        if (o instanceof PeopleDaily) {
            PeopleDaily peopleDaily = (PeopleDaily) o;
            System.out.println(peopleDaily.getClass().getSimpleName() + "'s msg -- >" + peopleDaily.getMsg());
        }

    }
}
